const express = require("express");
const router = express.Router();

const { login, register } = require("../services/userService");

/**  
 * @api {post} /login 登录  
 * @apiGroup User  
 * @apiVersion 1.0.0  
 * @apiName login  
 * @apiDescription 登录进入系统 
 *   
 * @apiParam {String} username 用户名称  
 * @apiParam {String} password 用户密码   
 *  
 * @apiSuccess {String} id The unique ID of the created user.  
 * @apiSuccess {String} username The username of the created user.  
 *  
 * @apiSuccessExample Success-Response:  
     HTTP/1.1 0 OK  
     {  
       "username": "admin",  
       "password": "admin123"  
     }  
 *  
 * @apiError {String} error Detailed error message.  
 *  
 * @apiErrorExample Error-Response:  
     HTTP/1.1 -1 Bad Request  
     {  
       "error": "Invalid username"  
     }  
 */
router.post("/login", login);
/**  
 * @api {post} /login 注册  
 * @apiGroup User  
 * @apiVersion 1.0.0  
 * @apiName register  
 * @apiDescription 注册用户
 *   
 * @apiParam {String} username 用户名称  
 * @apiParam {String} password 用户密码   
 *  
 * @apiSuccess {String} id The unique ID of the created user.  
 * @apiSuccess {String} username The username of the created user.  
 *  
 * @apiSuccessExample Success-Response:  
     HTTP/1.1 0 OK  
     {  
       "username": "admin",  
       "password": "admin123"  
     }  
 *  
 * @apiError {String} error Detailed error message.  
 *  
 * @apiErrorExample Error-Response:  
     HTTP/1.1 -1 Bad Request  
     {  
       "error": "Invalid username"  
     }  
 */
router.post("/register", register);

module.exports = router;
